/**
 * <pre>
 * 北京鹏润鸿途科技有限公司
 * Copyright (C): 2010
 * 
 * 文件名称：
 * com.nusof.iptv.service.impl.IptvServiceImpl.java
 * 
 * 文件描述: 
 * TODO
 * 
 * Notes:
 * 修改历史(作者/日期/改动描述):
 * 杨飞宇/2011-1-20/初始化版本。
 * </pre>
 */
package com.unis.iptv.service.impl;

import java.util.Date;

import javax.annotation.PostConstruct;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.unis.iptv.common.utils.Authentication;
import com.unis.iptv.common.utils.DateUtil;
import com.unis.iptv.common.utils.GlobalUtil;
import com.unis.iptv.service.IptvService;
import com.unis.iptv.service.LiveService;
import com.unis.iptv.service.VodService;

/**
 * @date 2011-1-20
 * @author 杨飞宇
 */
@Component("iptvService")
public class IptvServiceImpl implements IptvService {
	private static Log log = LogFactory.getLog("iptvCourse");
	private static Log errLog = LogFactory.getLog("iptvErrCourse");
	@Autowired
	private LiveService liveService;
	@Autowired
	private VodService vodService;
	
	@Override
	public void execute() {
		log.info(DateUtil.formatDateAndTime(new Date()) + "  本地程序START");
		try {
			if (Authentication.Auth()) {
				log.info("直播提取开始");
				liveService.execute();
				log.info("直播提取结束");
				log.info("点播提取开始");
				vodService.execute();
				log.info("点播提取结束");
			}
		} catch (Exception e) {
			errLog.error(e.getMessage());
			e.printStackTrace();
		}
		log.info(DateUtil.formatDateAndTime(new Date()) + "   程序执行结束！");
	}
	
	@PostConstruct
	public void injectConfig() {
		log.info("初始化开始");
		GlobalUtil.initConfiguration();
		log.info("初始化完成");
	}
}
